#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "handler.h"
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //八、new出一个场景对象
    this->sc = new myScene;
    //九、把场景放入ui上的graphicsView容器中
    this->ui->graphicsView->setScene(sc);
    connect(this->ui->btn_start,SIGNAL(clicked(bool)),this->sc,SLOT(startGame()));
    connect(this->ui->btn_pause,SIGNAL(clicked(bool)),this->sc,SLOT(pauseGame()));
    connect(this->ui->btn_stop,SIGNAL(clicked(bool)),this->sc,SLOT(stopGame()));
    this->score = 0;
    handler * hand = handler::getInstance();
    connect(hand,SIGNAL(beatMouse()),this,SLOT(UpdateScore()));
    connect(hand,SIGNAL(stopMouse()),this,SLOT(ClearScore()));
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::UpdateScore(){
    this->score += 3;
    this->ui->lcdNumber->display(this->score);
}
void MainWindow::ClearScore(){
    this->score = 0;
    this->ui->lcdNumber->display(this->score);
}
